#ifndef SVM_TRAIN_
#define SVM_TRAIN_

#include <iostream>
#include <vector>
#include <stdio.h>
#include "opencv2/opencv.hpp"

using namespace cv;

typedef enum {
  kForward = 1, // correspond to "has plate"
  kInverse = 0  // correspond to "no plate"
} SvmLabel;

typedef struct{
	cv::Mat samples_;
	cv::Mat responses_;
} trainData;

class SvmTrain {
public:
	typedef struct {
    std::string file;
    SvmLabel label;//correspond to "has plate"
	} TrainItem;

	SvmTrain(const char* plates_folder, const char* xml);

	void train();

private:
	void prepare();

	trainData tdata();

	CvSVM svm_;
	const char* plates_folder_;
	const char* svm_xml_;
	std::vector<TrainItem> train_file_list_;
};
///////////////////////////predict/////////////////////////////////////////////
class SvmPredict {
public:
	static SvmPredict* instance(string svmPath);
	bool plateGetScore(Mat &facePic, float &score);

private:
	SvmPredict(string svmPath);

	static SvmPredict* instance_;
	CvSVM svm_train;
    CvSVM svm_predict;
	const string svm_xml;	
};


#endif  // EASYPR_TRAIN_SVMTRAIN_H_
